Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display download progress for file downloads #2327

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

legoktm
Copy link
Member

@legoktm legoktm commented Dec 9, 2024

Status

Work in progress

TODO:

  • Visual alignment issue; need padding on the right side
  • update apparmor stuff?
  • tests?

Description

Display a vanilla progress bar for file downloads that simply shows how much of the file has been downloaded so far.

A new FileDownloadProgressBar widget replaces the existing animated spinner, and we inject a signal through to the SDK to pass the current progress back to the widget.

Fixes #1104.

Test Plan

  • Spin up dev server; then inside the container run NUM_SOURCES=10 --random-file-size 100000 to generate 10 sources with 100MB attachments
  • Download them, including starting multiple parallel downloads and switching to other sources
  • Progress bar continues to update as expected, etc.

Checklist

  • These changes should not need testing in Qubes
    • everything should be testable with the dev client, since no proxy changes are needed
  • I have updated the AppArmor profile
  • No database schema changes are needed

@legoktm legoktm requested a review from a team as a code owner December 9, 2024 23:50
@legoktm legoktm marked this pull request as draft December 9, 2024 23:50
@legoktm
Copy link
Member Author

legoktm commented Dec 10, 2024

So right now I've implemented an exponential moving average based on https://stackoverflow.com/questions/2779600/how-to-estimate-download-time-remaining-accurately; however I missed the comment which says, "EMA will only work if the time-sampling rate is about the same. If, for example the download is updated every 1 MB rather than every 1 second and the speed fluctuates the output will most likely be nonsense". Unfortunately that's exactly what we're doing, we update on chunks rather than on a regular time interval. Will require some more 🤔

@legoktm legoktm force-pushed the download-progress branch 2 times, most recently from cb0c67f to 1571296 Compare December 10, 2024 00:56
@legoktm
Copy link
Member Author

legoktm commented Dec 10, 2024

I got a smoothed version of the download speed to work (by adjusting the SMOOTHING_FACTOR to be relative to the time period), but there's a more practical problem: we only update the speed after we receive a chunk, so if it stalls, we don't update the speed and it'll get stuck at e.g. 4MB/s.

So I want to rework this a bit, I'll move the calculation stuff into the widget and we can use a QTimer to update the widget's speed on an actual time interval.

@legoktm legoktm force-pushed the download-progress branch 3 times, most recently from a8222ca to 6ae75e9 Compare December 11, 2024 00:26
Display a vanilla progress bar for file downloads that simply shows how
much of the file has been downloaded so far.

A new FileDownloadProgressBar widget replaces the existing animated
spinner, and we inject a signal through to the SDK to pass the current
progress back to the widget.

The widget both displays the overall total progress as a percentage and
also calculates the download speed by using an exponential moving
average to smooth it out. A timer runs every 100ms to recalculate the
speed.

A new utils.humanize_speed() is used to translate the raw bytes/second
into a human-readable version with a focus on keeping the length of the
string roughly consistent so there's less visual shifting.

Once the download has finished, an indeterminate progress bar is shown
while decrypting since we don't (currently) have a way to report
specific progress on that.

TODO:
* tests?

Fixes #1104.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display download progress
1 participant